package com.ln.cmsln.controller.hu;


import com.alibaba.fastjson.JSON;
import com.ln.cmsln.pojo.entity.hu.Rotation;
import com.ln.cmsln.pojo.entity.hu.Teacher;
import com.ln.cmsln.service.hu.RotationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Helen
 * @since 2022-03-31
 */
@RestController
@CrossOrigin
@Api(tags = "首页轮播图")
@RequestMapping("/api/rotation")
public class RotationController {

    @Resource
    private RotationService rotationService;


    @RequestMapping("getAll")
    public String getAll(){
        List<Rotation> list = rotationService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", 0);
        map.put("data", list);
        String json= JSON.toJSONString(map);
        return json;
    }

    @RequestMapping("/del")
    public boolean del(int rId){
        boolean b = rotationService.removeById(rId);
        return b;
    }


    @PostMapping("/save")
    public boolean save(Rotation rotation){
      return   rotationService.save(rotation);
    }

}

